/*
 * @(#)MaintHolidayRecordForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.setup.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;
import com.dcivision.setup.bean.HolidayRecord;

/**
  MaintHolidayRecordForm.java

  This class is the for web form purpose.

  @author      Weison Liang
  @company     DCIVision Limited
  @creation date   13/04/2005
  @version     $Revision: 1.6 $
*/

public class MaintHolidayRecordForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.6 $";

  private String workingCalendarID = null;
  private String holidayName = null;
  private String holidayType = String.valueOf(HolidayRecord.HOLIDAY_TYPE_PUBLIC);
  private String startDate = null;
  private String endDate = null;
  private String description = null;
  private String referenceFlag = HolidayRecord.REFERENCE_TYPE_RECORD;
  
  
  public MaintHolidayRecordForm() {
    super();
  }

  public String getWorkingCalendarID() { 
    return(this.workingCalendarID);
  }

  public void setWorkingCalendarID(String workingCalendarID) { 
    this.workingCalendarID = workingCalendarID;
  }

  public String getHolidayName() { 
    return(this.holidayName);
  }

  public void setHolidayName(String holidayName) { 
    this.holidayName = holidayName;
  }

  public String getHolidayType() { 
    return(this.holidayType);
  }

  public void setHolidayType(String holidayType) { 
    this.holidayType = holidayType;
  }

  public String getStartDate() { 
    return(this.startDate);
  }

  public void setStartDate(String startDate) { 
    this.startDate = startDate;
  }

  public String getEndDate() { 
    return(this.endDate);
  }

  public void setEndDate(String endDate) { 
    this.endDate = endDate;
  }

  public String getDescription() { 
    return(this.description);
  }

  public void setDescription(String description) { 
    this.description = description;
  }

  public String getReferenceFlag() { 
    return(this.referenceFlag);
  }
  
  public void setReferenceFlag(String referenceFlag) { 
    this.referenceFlag = referenceFlag;
  }
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setWorkingCalendarID(null);
    this.setHolidayName(null);
    //this.setHolidayType(null);
    this.setStartDate(null);
    this.setEndDate(null);
    this.setDescription(null);
    this.setReferenceFlag(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    HolidayRecord tmpHolidayRecord = new HolidayRecord();
    tmpHolidayRecord.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpHolidayRecord.setWorkingCalendarID(TextUtility.parseIntegerObj(this.getWorkingCalendarID()));
    tmpHolidayRecord.setHolidayName(this.getHolidayName());
    tmpHolidayRecord.setHolidayType(TextUtility.parseIntegerObj(this.getHolidayType()));
    tmpHolidayRecord.setStartDate(parseTimestamp(this.getStartDate()));
    tmpHolidayRecord.setEndDate(parseTimestamp(this.getEndDate()));
    tmpHolidayRecord.setDescription(this.getDescription());
    tmpHolidayRecord.setReferenceFlag(this.getReferenceFlag());
    tmpHolidayRecord.setRecordStatus(this.getRecordStatus());
    tmpHolidayRecord.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpHolidayRecord.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpHolidayRecord.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpHolidayRecord.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpHolidayRecord.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpHolidayRecord;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    HolidayRecord tmpHolidayRecord = (HolidayRecord)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpHolidayRecord.getID()));
    this.setWorkingCalendarID(TextUtility.formatIntegerObj(tmpHolidayRecord.getWorkingCalendarID()));
    this.setHolidayName(tmpHolidayRecord.getHolidayName());
    this.setHolidayType(TextUtility.formatIntegerObj(tmpHolidayRecord.getHolidayType()));
    this.setStartDate(formatTimestamp(tmpHolidayRecord.getStartDate()));
    this.setEndDate(formatTimestamp(tmpHolidayRecord.getEndDate()));
    this.setDescription(tmpHolidayRecord.getDescription());
    this.setReferenceFlag(tmpHolidayRecord.getReferenceFlag());
    this.setRecordStatus(tmpHolidayRecord.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpHolidayRecord.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpHolidayRecord.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpHolidayRecord.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpHolidayRecord.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpHolidayRecord.getUpdateDate()));
  }
}
